/*
 * @Description:
 * @Author:
 * @Date: 2024-10-28 23:50:46
 * @LastEditTime: 2025-02-16 21:24:42
 * @LastEditors: XXX
 */
import type { RouteRecordRaw } from 'vue-router'
import type { PermissionState } from './state'
import type { MutationTree } from 'vuex'
import { PermissionMutationType } from './mutation-types'
import { constantRoutes } from '@/router'

export type Mutations<S = PermissionState> = {
  [PermissionMutationType.SET_ROUTES] (state: S, routes: RouteRecordRaw[]): void
}

export const mutations: MutationTree<PermissionState> & Mutations = {
  [PermissionMutationType.SET_ROUTES]: function (state: PermissionState, routes: RouteRecordRaw[]): void {
    state.routes = constantRoutes.concat(routes)
    state.routes = routes
  }
}
